<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue@next"></script>
</head>

<body>
    <div id="app"></div>
</body>
<script>
    let vm = {
        template: `
                    <div>
                        {{name}}
                        {{age}}
                    </div>
                `,
        setup () {
            const { reactive, toRefs, toRef } = Vue
            let obj = reactive({ name: 'GalaxySa' })
            let { name } = toRefs(obj)
            // 若希望对象中新增的数据也统一具备响应式的能力
            // toRef 让新增的属性具备响应式
            let age = toRef(obj, 'age')
            setTimeout(() => {
                obj.name = 'FoggySea'
                // toRef数据修改方式
                age.value = 18
            }, 1000)
            console.log(name);
            return { name, age }
        }
    }
    let app = Vue.createApp(vm)
    app.mount('#app')
</script>

</html>